package utils;

import java.util.List;

/**
 * 缓冲区
 *
 * @author waxijiang
 */
public class Buffer {
    private String content = "";
    private static Buffer buffer;

    private Buffer() {
    }

    public static Buffer getInstance() {
        if (buffer == null) {
            buffer = new Buffer();
        }
        return buffer;
    }

    public void write(String content) {
        if ("".equals(this.content)) {
            this.content = content;
        } else {
            this.content += "\n" + content;
        }
    }

    public String getContent(){
        return this.content;
    }

    public void flush(){
        this.content = "";
    }

    public void output() {
        if (!"".equals(content)) {
            System.out.println(this.content);
            this.content = "";
        }
    }
}
